/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jdAgregarActividades.java
 *
 * Created on 05-ago-2010, 12:58:10
 */

package Licitaciones;

import administracion.BeanBinding.TblBeanBindingDetalleLicitacionActividad;
import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.ArrayListTableModel;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_Importar;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import administracion.propiedades.Propiedades;
import java.awt.event.KeyEvent;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.entity.DetalleLicitacion;
import suministros.ejb30.entity.DetalleLicitacionActividad;
import suministros.ejb30.entity.Tipo;

/**
 *
 * @author Diana
 */
public class jdAgregarActividades extends javax.swing.JDialog {
    List<TblBeanBindingDetalleLicitacionActividad> detalleActividades;
    jifRegistrarLicitacion padre;
    jifRegistrarLicitacion reg;
    String codigo;
    String suministro;
    String descripcion;
    private BindingGroup bindingGroup;
    private JTableBinding jTableBinding;
    private int hojaExcel;
    private ArrayList dat;
    int filas;
    int filaElegida;
    BigDecimal montoTotalSumi;
    Boolean estado;
    BigDecimal montoTotal;
    /** Creates new form jdAgregarActividades */
    public jdAgregarActividades(jifRegistrarLicitacion padre,java.awt.Frame parent, boolean modal, String codigo, String suministro, String descripcion, int filaElegida, BigDecimal monto) {
        
        super(parent, modal);
        this.padre=padre;
        initComponents();
        this.filaElegida=filaElegida;
        this.codigo=codigo;
        this.suministro=suministro;
        this.descripcion=descripcion;
        this.jtfLicitacion.setText(codigo);
        this.jtfSuministro.setText(suministro);
        this.jtfDescripcion.setText(descripcion);
        this.jtfLicitacion.setEditable(false);
        this.jtfSuministro.setEditable(false);
        this.jtfDescripcion.setEditable(false);
        this.montoTotalSumi=monto;
        this.jbtnSeleccion.requestFocus();
    }
     void setPadreDetalle(jifRegistrarLicitacion reg){
        this.reg=reg;
    }
     public void cargarExcel(){
        hojaExcel=0;
        ArrayList identificadores = null;
        ArrayList clases = null;
        Utiles_Importar ui = new Utiles_Importar( new File( this.jtfDireccion.getText().trim() ) );
        
        try{
            ui.setNumColumnas( 6 ); //Definimos que son 9 columnas
            dat = ui.getDatosHoja( this.hojaExcel ); //Definimos obtener los datos de la hoja 0
            identificadores = ui.getIdentificadores();
            clases = ui.getClases();
            filas=ui.getNumFilas()-1;

            this.jtDetalleSuministro.setModel( new ArrayListTableModel( dat, identificadores, clases ) );
            //Utiles_Varios.centraCeldasTabla( this.jtfDireccion );
            if( dat.size() > 0 ){
                this.jbtnMigrar.setEnabled( true );
            }
            this.jtfDireccion.setEnabled( false );
            this.jbtnMigrar.setEnabled( false );
            this.jbtnAceptar.setEnabled(true);
            this.jbtnEliminar.setEnabled(true);
            this.jbtnAceptar.requestFocus();

            this.jtfTotal.setText(filas+"");
             montoTotal=BigDecimal.ZERO;
              for (int i=0; i<filas; i++) {
              BigDecimal monto= new BigDecimal(Float.parseFloat(this.jtDetalleSuministro.getValueAt(i, 4).toString())*Float.parseFloat(this.jtDetalleSuministro.getValueAt(i, 5).toString()));
              montoTotal= montoTotal.add(monto);
            }
             montoTotal.setScale(2);
            this.jtfMonto.setText(montoTotal.setScale(2)+"");
            this.jbtnAceptar.setEnabled(true);

        }catch( Exception er ){
            Utiles_MensajesDialogo.mensajeAlerta( "Verifique si el archivo que desea cargar es el correcto" );
        }
     }
     public void cancelarMigracion(){
           detalleActividades=  new ArrayList<TblBeanBindingDetalleLicitacionActividad>();
           this.actualizarTabla();
           this.jtfMonto.setText("");
           this.jtfTotal.setText("");
           this.jbtnMigrar.setEnabled(true);
           this.jbtnEliminar.setEnabled(false);
     }
     
     public void actualizarTabla(){
        this.bindingGroup = new BindingGroup();
        this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.detalleActividades, this.jtDetalleSuministro);

        JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${codTipoAct}"));

        columnBinding0.setColumnName("TipoActividad");
        columnBinding0.setColumnClass(String.class);
        columnBinding0.setEditable(false);

        JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${codItem}"));

        columnBinding1.setColumnName("CodigoItem");
        columnBinding1.setColumnClass(String.class);
        columnBinding1.setEditable(false);

        JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${descripcion}"));

        columnBinding2.setColumnName("Descripcion");
        columnBinding2.setColumnClass(String.class);
        columnBinding2.setEditable(true);

        JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${tipoUnidad}"));

        columnBinding3.setColumnName("Unidad");
        columnBinding3.setColumnClass(String.class);
        columnBinding3.setEditable(false);

        JTableBinding.ColumnBinding columnBinding4 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad}"));

        columnBinding4.setColumnName("Cantidad");
        columnBinding4.setColumnClass(BigDecimal.class);
        columnBinding4.setEditable(false);

         JTableBinding.ColumnBinding columnBinding5 = this.jTableBinding.addColumnBinding(ELProperty.create("${costo}"));

        columnBinding5.setColumnName("Costo.Unit");
        columnBinding5.setColumnClass(BigDecimal.class);
        columnBinding5.setEditable(false);

        this.bindingGroup.addBinding(this.jTableBinding);
        this.bindingGroup.bind();

        int[] porcentajes= {5,10,20,45,10,10};
        try {
            Utiles_Tabla.definirAnchoColumnasJTable(jtDetalleSuministro, porcentajes);
             //MiTablePrint.autoSizeTableColumns(this.jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jdAdministrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
        }

     }
     public void registrarActividad(){
         List<DetalleLicitacionActividad> lista= new ArrayList();
          for (int i=0; i<filas; i++) {
          DetalleLicitacionActividad detall = new DetalleLicitacionActividad(this.jtfLicitacion.getText(),this.jtfSuministro.getText(), Integer.parseInt(this.jtDetalleSuministro.getValueAt(i,0).toString()), this.jtDetalleSuministro.getValueAt(i,1).toString());
          detall.setDescripcion(this.jtDetalleSuministro.getValueAt(i,2).toString());
          detall.setTipoUnidad(this.jtDetalleSuministro.getValueAt(i, 3).toString());
          detall.setCantidad( new BigDecimal(this.jtDetalleSuministro.getValueAt(i,4).toString()));
          detall.setCostoUnitario(new BigDecimal(this.jtDetalleSuministro.getValueAt(i,5).toString()));
          detall.setMontoTotal(detall.getCantidad().multiply(detall.getCostoUnitario()));
          detall.setCantidadAdquirida(BigDecimal.ZERO);
          detall.setMontoAdquirido(BigDecimal.ZERO);
          lista.add(detall);
         }
        try {
            GestionPedidosDelegate.getInstance().insertarLicitacionActividad(Propiedades.getUsuario(),Propiedades.getMac(),lista, montoTotalSumi);
        } catch (Exception ex) {
            Logger.getLogger(jdAgregarActividades.class.getName()).log(Level.SEVERE, null, ex);
        }
     }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jtDetalleSuministro = new javax.swing.JTable();
        this.jtDetalleSuministro.getTableHeader().setReorderingAllowed(false) ;
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jtfSuministro = new javax.swing.JTextField();
        jtfDescripcion = new javax.swing.JTextField();
        jtfLicitacion = new javax.swing.JTextField();
        jbtnMigrar = new javax.swing.JButton();
        jbtnAceptar = new javax.swing.JButton();
        jbtnCancelar = new javax.swing.JButton();
        jbtnEliminar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jtfDireccion = new javax.swing.JTextField();
        jbtnSeleccion = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtfTotal = new javax.swing.JTextField();
        jtfMonto = new javax.swing.JTextField();
        jbtImprimir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AGREGAR ACTIVIDADES");

        jtDetalleSuministro.setFont(new java.awt.Font("Arial", 0, 12));
        jtDetalleSuministro.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "TIPO ACTIVIDAD", "CODIGO", "DESCRIPCION", "UNIDAD", "CANTIDAD", "COSTO UNITARIO"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Float.class, java.lang.Float.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jtDetalleSuministro.setEnabled(false);
        jScrollPane2.setViewportView(jtDetalleSuministro);

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("COD. LICITACION:");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("COD. SUMINISTRO:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setText("DESC. SUMINISTRO:");

        jtfSuministro.setFont(new java.awt.Font("Arial", 0, 12));

        jtfDescripcion.setFont(new java.awt.Font("Arial", 0, 12));

        jtfLicitacion.setFont(new java.awt.Font("Arial", 0, 12));

        jbtnMigrar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtnMigrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_export.png"))); // NOI18N
        jbtnMigrar.setText("MIGRAR DE EXCEL");
        jbtnMigrar.setEnabled(false);
        jbtnMigrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnMigrarActionPerformed(evt);
            }
        });

        jbtnAceptar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtnAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbtnAceptar.setText("ACEPTAR");
        jbtnAceptar.setEnabled(false);
        jbtnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnAceptarActionPerformed(evt);
            }
        });
        jbtnAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtnAceptarKeyPressed(evt);
            }
        });

        jbtnCancelar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbtnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbtnCancelar.setText("CERRAR");
        jbtnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnCancelarActionPerformed(evt);
            }
        });

        jbtnEliminar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/remove.png"))); // NOI18N
        jbtnEliminar.setText("CANCELAR MIGRACION");
        jbtnEliminar.setEnabled(false);
        jbtnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnEliminarActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("UBICACION:");

        jtfDireccion.setFont(new java.awt.Font("Arial", 0, 12));

        jbtnSeleccion.setFont(new java.awt.Font("Arial", 1, 12));
        jbtnSeleccion.setText("SELECCIONAR ARCHIVO");
        jbtnSeleccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSeleccionActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("TOTAL DE ACTIVIDADES:");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("MONTO TOTAL:");

        jtfTotal.setFont(new java.awt.Font("Arial", 0, 12));
        jtfTotal.setEnabled(false);

        jtfMonto.setFont(new java.awt.Font("Arial", 0, 12));
        jtfMonto.setEnabled(false);

        jbtImprimir.setFont(new java.awt.Font("Arial", 1, 12));
        jbtImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_print.png"))); // NOI18N
        jbtImprimir.setText("IMPRIMIR");
        jbtImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtImprimirActionPerformed(evt);
            }
        });
        jbtImprimir.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtImprimirKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1)
                                .addComponent(jLabel2))
                            .addGap(10, 10, 10)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jtfLicitacion)
                                .addComponent(jtfSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(30, 30, 30)
                            .addComponent(jLabel3)
                            .addGap(18, 18, 18)
                            .addComponent(jtfDescripcion))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jbtnSeleccion)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel4)
                                    .addGap(48, 48, 48)
                                    .addComponent(jtfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jbtnMigrar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jbtnEliminar, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfMonto)
                            .addComponent(jtfTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 146, Short.MAX_VALUE)
                        .addComponent(jbtnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtImprimir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnCancelar)))
                .addContainerGap(10, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfLicitacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jtfDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtnSeleccion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jtfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtnMigrar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnEliminar)))
                .addGap(12, 12, 12)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtfTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtfMonto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnCancelar)
                    .addComponent(jbtImprimir)
                    .addComponent(jbtnAceptar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAceptarActionPerformed
      int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro que desea registrar esta licitacion?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
         if(res==javax.swing.JOptionPane.YES_OPTION){       
             if(montoTotalSumi.compareTo(montoTotal)!=0){
              
                int res1 = javax.swing.JOptionPane.showConfirmDialog( this,"El monto total migrado no coincide con el ingresado en la licitacion \n ¿Desea modificar el monto del suministro en la licitacion",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
                 if(res1==javax.swing.JOptionPane.YES_OPTION){               
                    montoTotalSumi=montoTotal;
                    estado=true;
                 }
                 else
                    estado=false;
            }
            else{
                estado=true;
            }
             if(estado){
             try {
                this.registrarActividad();
                Utiles_MensajesDialogo.mensajeExito();
                reg.jtDetalleSuministro.setValueAt("MIGRADA", filaElegida , 5);
                reg.jtDetalleSuministro.setValueAt(montoTotalSumi, filaElegida, 4);
                /*if(dif>0){
                     reg.jtfMonto.setText(Float.parseFloat(reg.jtfMonto.getText())+dif+"");
                }
                else{
                     reg.jtfMonto.setText(Float.parseFloat(reg.jtfMonto.getText())-dif+"");
                }*/
               
                reg.jtDetalleSuministro.setValueAt(montoTotalSumi,filaElegida, 3);
                this.jbtnAceptar.setEnabled(false);
                } catch (Exception ex) {
                    Logger.getLogger(jifRegistrarLicitacion.class.getName()).log(Level.SEVERE, null, ex);
                    Utiles_MensajesDialogo.mensajeError("No se puedo registrar las actividades");
               }
             }
             else{
                 Utiles_MensajesDialogo.mensajeAlerta("Los montos totales no coinciden");
             }
                
         }
    }//GEN-LAST:event_jbtnAceptarActionPerformed

    private void jbtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCancelarActionPerformed
      int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
            padre.actualizaTablaDetalle();
        }
}//GEN-LAST:event_jbtnCancelarActionPerformed

    private void jbtnMigrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnMigrarActionPerformed
           this.cargarExcel();
    }//GEN-LAST:event_jbtnMigrarActionPerformed

    private void jbtnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnEliminarActionPerformed
           this.cancelarMigracion();
    }//GEN-LAST:event_jbtnEliminarActionPerformed

    private void jbtnSeleccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSeleccionActionPerformed
       JFileChooser jfc = new JFileChooser();    
       jfc.setAcceptAllFileFilterUsed(false);
        FileNameExtensionFilter fnef= new FileNameExtensionFilter("XLS & ODS","XLS","ODS");
        jfc.setMultiSelectionEnabled( false );
        jfc.setFileFilter(fnef);
        int returnVal = jfc.showOpenDialog( this );
        if( returnVal == JFileChooser.APPROVE_OPTION ){
            this.jtfDireccion.setText( jfc.getSelectedFile().toString() );
            this.jbtnMigrar.setEnabled(true);
            
        }else{
            this.jtfDireccion.setText( "" );
        }
        
    }//GEN-LAST:event_jbtnSeleccionActionPerformed

    private void jbtnAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtnAceptarKeyPressed
       if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbtnAceptar.doClick();
        }
    }//GEN-LAST:event_jbtnAceptarKeyPressed

    private void jbtImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtImprimirActionPerformed

        MiTablePrint pp = new MiTablePrint(this.jtDetalleSuministro, "ACTIVIDADES DE LICITACIONES", "DETALLE DE ACTIVIDADES DE UNA LICITACION");
        pp.showPrintPreview();
}//GEN-LAST:event_jbtImprimirActionPerformed

    private void jbtImprimirKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtImprimirKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbtImprimir.doClick();
        }
}//GEN-LAST:event_jbtImprimirKeyPressed

    /**
    * @param args the command line arguments
    */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbtImprimir;
    private javax.swing.JButton jbtnAceptar;
    private javax.swing.JButton jbtnCancelar;
    private javax.swing.JButton jbtnEliminar;
    private javax.swing.JButton jbtnMigrar;
    private javax.swing.JButton jbtnSeleccion;
    private javax.swing.JTable jtDetalleSuministro;
    private javax.swing.JTextField jtfDescripcion;
    private javax.swing.JTextField jtfDireccion;
    private javax.swing.JTextField jtfLicitacion;
    private javax.swing.JTextField jtfMonto;
    private javax.swing.JTextField jtfSuministro;
    private javax.swing.JTextField jtfTotal;
    // End of variables declaration//GEN-END:variables



}
